package com.starsea.book.ui.newpage.pop

import android.content.Context
import android.widget.ImageView
import android.widget.TextView
import com.lxj.xpopup.core.CenterPopupView
import com.starsea.book.R
import com.starsea.book.ui.newpage.normalview.RadiusLinearLayout
import com.starsea.book.ui.newpage.utils.loadNormalImage

/**
 * @author Lee
 * @createTime 2023-08-04 16 GMT+8
 */
class ActivityPop(
    var mContext: Context,
    var eventContent: String = "确定要删除该账户吗？",
    var eventImg: String = "取消",
    var eventName: String = "确认删除",
    var eventUrl: String = "确认删除",
    var onResult: ((type: Int, eventUrl: String) -> Unit)? = null
) :
    CenterPopupView(mContext) {

    lateinit var iv_image: ImageView
    lateinit var tv_content: TextView
    lateinit var tv_title: TextView
    lateinit var rll_confim: RadiusLinearLayout
    lateinit var rll_cancle: RadiusLinearLayout


    override fun getImplLayoutId(): Int {
        return R.layout.layout_activity_pop
    }

    override fun onCreate() {
        super.onCreate()

        tv_content = findViewById(R.id.tv_content)
        tv_title = findViewById(R.id.tv_title)
        iv_image = findViewById(R.id.iv_image)

        rll_cancle = findViewById(R.id.rll_cancle)
        rll_confim = findViewById(R.id.rll_confim)


        iv_image.loadNormalImage(mContext, eventImg)

        tv_title.text = eventName
        tv_content.text = eventContent


        rll_cancle.setOnClickListener {
            onResult!!.invoke(0, eventUrl)
            dismiss()
        }
        rll_confim.setOnClickListener {
            onResult!!.invoke(1, eventUrl)
            dismiss()
        }

    }


}